<?
require '../inc.php';
if(!urs)
{
    g::gowin(surl::get('www')."login.php?ourl=".urlencode(surl::url()));
    exit();   
}
class core_myindex
{
   	/**
   	 * 功能:首页 加公告
   	 */
   	public function main()
   	{
   	    global $scfg;
   	    $db_help 	= &new db($scfg['db']['help']);
		$my_affiche = $db_help->dataArray("select id,chk_yn,cats,author,subject,save_time from my_affiche order by id desc limit 0,4");
		tpl::assign('my_affiche',$my_affiche);
   	}
   	/**
   	 //TODO:buy_ok 已购买的商品
   	 */
    public function buy_ok()
    {
        global $scfg,$db_member,$page,$rows;
        $where = array('where'=> " where 1 ");
		$where['where'] 		.= " and urs = :urs  and `upload` = :upload  ";
		$where['bind']['upload']= 0;
		$where['bind']['urs'] 	= urs;
		$table 		= "goods_info";
		$db_goods 	= new db($scfg['db']['goods']);
		$pg			= pg::sp($db_goods,$table,$where,$page,$rows);
		$rs 		= $db_goods->dataArray("select * from {$table} {$where['where']} limit {$pg['begin']},".$rows,$where['bind']);
		//echo $db_goods->getsql();
		tpl::assign('pg',$pg);
		tpl::assign('rs',$rs);
    }
    /**
   	 * TODO:buy_fav 收藏|追蹤..
   	 */
    public function buy_fav()
    {
        global $scfg,$db_member,$page,$rows;
        $where = array('where'=> " where 1 ");
        $table 		= "goods_info";
		$db_goods 	= new db($scfg['db']['goods']);
		$pg			= pg::sp($db_goods,$table,$where,$page,$rows);
		$rs 		= $db_goods->dataArray("select * from {$table} {$where['where']} limit {$pg['begin']},".$rows,$where['bind']);
		//echo $db_goods->getsql();
		tpl::assign('pg',$pg);
		tpl::assign('rs',$rs);
    }
    /**
     * 
     */
    public function buy_fav_shop()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:buy_p_ing 竞拍中的商品
   	 */
    public function buy_p_ing()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 //TODO:buy_p_ok 已得標商品
   	 */
    public function buy_p_ok()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:buy_p_lose 未得标的商品
   	 */
    public function buy_p_lose()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:buy_review 我对卖家的留言
   	 */
    public function buy_review()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_open_shop 開通拍樂小店
   	 */
    public function sell_open_shop()
    {
        global $my_log;
        if($my_log['shop_check'] == 1)
		{
		    echo g::msg("提示,你的小店功能已开通!");
		    g::gowin("?");
		}
    }
    /**
   	 TODO:sell_depot 仓库里的商品
   	 */
    public function sell_depot()
    {
        global $scfg,$page,$rows;
        $begin  = $_REQUEST['begin'];
		$end    = $_REQUEST['end'];
		$name 	= $_REQUEST['name'];
		$where = array('where'=> " where 1 ");
		if($begin != $end && $begin && $end)
		{
			$where['where'] 		.= " and gYmd >= :begin and  gYmd <= :end ";
			$where['bind']['begin'] = $begin;
			$where['bind']['end'] 	= $end;
		}
		$where['where'] 		.= " and urs = :urs  and `upload` = :upload  ";
		$where['bind']['upload']= 0;
		$where['bind']['urs'] 	= urs;
		if($name)
		{
			$where['where'] 		.= "  and `sTitle` LIKE :sTitle ";
			$where['bind']['sTitle']= "%{$name}%";
		}
		$table 		= "goods_info";
		$db_goods 	= new db($scfg['db']['goods']);
		$pg			= pg::sp($db_goods,$table,$where,$page,$rows);
		$rs 		= $db_goods->dataArray("select * from {$table} {$where['where']} limit {$pg['begin']},".$rows,$where['bind']);
		//echo $db_goods->getsql();
		tpl::assign('pg',$pg);
		tpl::assign('rs',$rs);
    }
    /**
   	 * TODO:sell_selling 出售中的商品
   	 */
    public function sell_selling()
    {
        global $scfg,$page,$rows;
        $begin  = $_REQUEST['begin'];
		$end    = $_REQUEST['end'];
		$name 	= $_REQUEST['name'];
		$where = array('where'=> " where 1 ");
		if($begin != $end && $begin && $end)
		{
			$where['where'] 		.= " and gYmd >= :begin and  gYmd <= :end ";
			$where['bind']['begin'] = $begin;
			$where['bind']['end'] 	= $end;
		}
		$where['where'] 		.= " and urs = :urs  and `upload` = :upload  ";
		$where['bind']['upload']= 1;
		$where['bind']['urs'] 	= urs;
		if($name)
		{
			$where['where'] 		.= "  and `sTitle` LIKE :sTitle ";
			$where['bind']['sTitle']= "%{$name}%";
		}
		$table 		= "goods_info";
		$db_goods 	= new db($scfg['db']['goods']);
		$pg			= pg::sp($db_goods,$table,$where,$page,$rows);
		$rs 		= $db_goods->dataArray("select * from {$table} {$where['where']} limit {$pg['begin']},".$rows,$where['bind']);
		//echo $db_goods->getsql();
		tpl::assign('pg',$pg);
		tpl::assign('rs',$rs);
    }
    /**
   	 TODO:sell_sold 全部卖出交易
   	 */
    public function sell_sold()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_manage_basicset 基本设置
   	 */
    public function sell_manage_basicset()
    {
        global $scfg;
        $db_goods = new db($scfg['db']['goods']);
		$rs_cat   = shop::id2name($db_goods);
		$rs		  = $db_goods->row("select * from shop_info where urs = ? ",urs);
		if($rs)
		{
		    $rss		  = $db_goods->row("select * from shop_info_desc where urs = ? ",urs);
			$rs["desc"]   = $rss["desc"];
		}
		tpl::assign('rs_cat',$rs_cat);
		tpl::assign('rs',$rs);
    }
    /**
   	 TODO:sell_manage_updateBBSEntry 公告设置
   	 */
    public function sell_manage_updateBBSEntry()
    {
        global $scfg;
        $db_goods = new db($scfg['db']['goods']);
		$rs		  = $db_goods->row("select * from shop_info where urs = ? ",urs);
		tpl::assign('rs',$rs);
    }
    /**
   	 TODO:sell_manage_sort 自定义分类
   	 */
    public function sell_manage_sort()
    {
        global $scfg;
        $db_goods 	= new db($scfg['db']['goods']);
		$where = array(
			"str" => " where urs = ? ",
			"bind"=>urs
		);
		$rs = $db_goods->dataArray("select * from shop_class_id {$where['str']} order by taxis limit 0,20",$where['bind']);
		//echo $db_goods->getsql();
		tpl::assign('rs',$rs);
    }
    /**
   	 TODO:sell_manage_recommend 店铺推荐位
   	 */
    public function sell_manage_recommend()
    {
        global $scfg;
        $db_goods 	= new db($scfg['db']['goods']);
        tpl::assign('rs',shop::shoprecommend($db_goods,urs));
    }
    /**
   	 TODO:sell_manage_shopStyle 美观设置
   	 */
    public function sell_manage_shopStyle()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_msg_me 在店铺的留言
   	 */
    public function sell_msg_me()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_msg_pct 在商品的留言
   	 */
    public function sell_msg_pct()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	TODO:sell_shop_about 編輯關於我
   	 */
    public function sell_shop_about()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_shop_call 編輯聯絡我
   	 */
    public function sell_shop_call()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_shop_msg 設定結標通知信
   	 */
    public function sell_shop_msg()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_shop_ad 宣傳我的賣場
   	 */
    public function sell_shop_ad()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_shop_link 邮寄方式设置
   	 */
    public function sell_shop_link()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_shop_im 即时联络工具设置
   	 */
    public function sell_shop_im()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_shop_ban 設定賣場黑名單
   	 */
    public function sell_shop_ban()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:sell_auto 搬家發財車
   	 */
    public function sell_auto()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:rate_manage 评价管理
   	 */
    public function rate_manage()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:rate_law_list 投诉举报
   	 */
    public function rate_law_list()
    {
        global $scfg,$db_member,$page,$rows;
    }
    /**
   	 //TODO:user_im 即時通设置
   	 */
    public function user_im()
    {
        global $scfg,$db_member;
        $where = array(
			"str" => " where urs = ? ",
			"bind"=>urs
		);
		$rs = $db_member->row("select * from member_im {$where['str']} limit 1",$where['bind']);
		//echo $db_member->getsql();
		tpl::assign('rs',$rs);
    }
    /**
   	 TODO:user_info 个人资料设置
   	 */
    public function user_info()
    {
        global $scfg,$db_member,$page,$rows;
        $where = array(
			"str" => " where urs = ? ",
			"bind"=>urs
		);
		$rs = $db_member->row("select * from member_base {$where['str']} limit 1",$where['bind']);
		//print($rs);
		if(!$rs)
		{
		    $rs=$db_member->row("select mail as email from member_main  {$where['str']} limit 1",$where['bind']);
			$rs["birthday_yy"] 			= date("Y")-20;
			$rs["country"]     			= "中国";
			$rs["address_province_tw"]  = 1;
			//$rs["address_province"]     = "台湾";
			$rs["address_city"]     	= 18;
			$rs["address_borough"]      = 266;
			$rs["zone_country"]= 886;
		}
		if($rs["address_province_tw"])
		{
		    $rs["address_province_o"] = $rs["address_city_o"] =$rs["address_borough_o"]="";
		}else
		{
		    $rs["address_province_o"] = $rs["address_province"];
		    $rs["address_city_o"] 	  = $rs["address_city"];
		    $rs["address_borough_o"]  = $rs["address_borough"];
		    $rs["address_province"]   = $rs["address_city"] =$rs["address_borough"]="";
		}
		//echo $db_member->getsql();
		tpl::assign('rs',$rs);
    }
    /**
   	 TODO:user_add  常用收货地址
   	 */
    public function user_add()
    {
        global $scfg,$db_member,$page,$rows;
        $where = array(
			"str" => " where urs = ? ",
			"bind"=>urs
		);
		$rs = $db_member->dataArray("select * from member_addr {$where['str']} limit 0,20",$where['bind']);
		tpl::assign('rs',$rs);
    }
    /**
   	 TODO:user_pwd  更改帐户密码
   	 */
    public function user_pwd()
    {
       // global $scfg,$db_member,$page,$rows;
    }
    /**
   	 TODO:user_safe 密码保护设置
   	 */
    public function user_safe()
    {
        global $scfg,$db_member,$page,$rows;
        $where = array(
			"str" => " where urs = ? ",
			"bind"=>urs
		);
		$rs = $db_member->row("select * from member_safe {$where['str']} limit 1",$where['bind']);
		$init = ($rs && $rs["ssn"]&& $rs["safe_email"]&& $rs["safe_pwd"]&& $rs["question1"]&& $rs["answer1"]&& $rs["question2"]&& $rs["answer2"])?1:0;
		tpl::assign('init',$init);
    }
    /**
     * 
     */
    public function msg_affiche()
    {
        
    }
    public function msg_system()
    {
        
    }
    public function msg_my_get()
    {
        
    }
    public function msg_my_send()
    {
        
    }
    public function msg_my_outline()
    {
        
    }
    public function msg_my_sended()
    {
        
    }
    public function msg_my_miss()
    {
        
    }
    /**
   	 TODO:help_my_affiche 拍樂公告
   	 */
    public function help_my_affiche()
    {
        global $scfg,$db_member,$page,$rows;
        $id 		= (int)$_GET['id'];
		$db_help 	= &new db($scfg['db']['help']);
		$my_affiche = $db_help->row("select * from my_affiche where id=? limit 0,1",$id);
		tpl::assign('my_affiche',$my_affiche);
    }
    /**
   	 TODO:note_email_check 邮箱绑定
   	 */
    public function note_email_check()
    {
        global $scfg,$db_member,$page,$rows;
        $my_log  	=  $db_member->row("select * from member_log where urs = ? ",urs);
		$my_main 	=  $db_member->row("select * from member_main where urs = ? ",urs);
		tpl::assign('my_log',$my_log);
		tpl::assign('my_main',$my_main);	
    }
}
$act  = isset($_GET['act'])?$_GET['act']:'main';
$page = isset($_GET['page'])?(int)$_GET['page']:1;
$rows = 10;
$db_member 	= new db($scfg['db']['member']);
$my_log  	= $db_member->row("select * from member_log where urs = ? ",urs);
//记日志
u::times();
//日志查出日志
tpl::assign("my_log",$my_log);
//下面是路由
route("core_myindex",$act);
tpl::assign("myContentTpl","z_{$act}.my.tpl.php");
tpl::display("my/index.my.tpl.php");
exit();
?>